﻿@model EvertonApp.AdminWeb.Models.ComentarioModel

@{
    ViewBag.Title = "Foro";
}


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>

<div id="global">

@using (Ajax.BeginForm("FiltroComentario", "Post", FormMethod.Post, new AjaxOptions { UpdateTargetId = "divGridComentarios" }, new { @id = "formularioComentario", enctype = "multipart/form-data" }))
{ 
@Html.HiddenFor(mod => mod.desdeFormulario)
<center>
    <div>
        <table>
            <tr>
                <td>
                   @Html.TextBoxFor(mod => mod.Filtro, new {placeholder ="buscar...", id = "Filtro", name = "FiltroComentario", @class = "filtro", @Value = String.Empty } as object)
                </td>
                <td>
                    <button type="submit" value="Filtrar" id="btnFiltrar" class="btn btn-primary" >Filtrar</button>
                </td>    
                <td>
                     @Ajax.ActionLink("Insertar", "Create", "Post", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup();limpiarCampos();" }, new { @class = "btn btn-primary btn-large" })
                </td>            
            </tr>
        </table>
    </div>
</center>  
}

<div id="divGrillaComentarios">
    @Html.Partial("_grillaComentarios", Model)
</div>

</div>

<script type="text/javascript"> 
    function openPopup() {
        $('#myModal').modal('show');
    }

    function limpiarCampos() {
        $('.filtro').each(function () {
            $(this).val('');
        });

    }
</script>